<template>
	<view>
		<web-view :src="mapUrl"></web-view>
	</view>
</template>

<script>
import {
	getRepairView,
} from "@/apis/workOrder.js";

export default {
	data() {
		return {
			id: '',
			mapUrl: '',
		};
	},
	async onLoad(option) {
		this.id = option.id
		const res = await getRepairView({
			RepairId: this.id
		})
		if (res.MsgCode != 0) return
		console.log('fetchRepairView------->', res)

		const zoneInfo = uni.getStorageSync('zoneInfo') || false
		const pi = zoneInfo.findIndex(o => o.id === res.data.Zone1)
		const provIdx = pi != -1 ? pi : 0
		const pName = zoneInfo[provIdx].name

		const ci = zoneInfo[provIdx].citys.findIndex(o => o.id === res.data.Zone2)
		const cityIdx = ci != -1 ? ci : 0
		const cName = zoneInfo[provIdx].citys[cityIdx].name

		const ti = zoneInfo[provIdx].citys[cityIdx].towns.findIndex(o => o.id === res.data.Zone3)
		const townIndex = ti != -1 ? ti : 0
		const tName = zoneInfo[provIdx].citys[cityIdx].towns[townIndex].name
		this.mapUrl = `https://apis.map.qq.com/uri/v1/search?keyword=${res.data.Addr || pName+cName+tName}&region=${pName+cName+tName}`
	},
}
</script>

<style lang="scss"></style>
